<!--
 * @Author: 卢景滔
 * @Date: 2021-09-24 09:26:29
 * @LastEditTime: 2021-11-16 16:51:44
 * @LastEditors: 卢景滔
 * @Description: app-h5通讯测试
-->
<!DOCTYPE html>
<html lang="en">
  <head>
    <meta charset="UTF-8" />
    <meta http-equiv="X-UA-Compatible" content="IE=edge" />
    <meta name="viewport" content="width=device-width, initial-scale=1.0" />
    <title>app-h5通讯测试</title>
  </head>
  <script type="text/javascript">
    function appCallWeb(type, data) {
      var printEle = document.getElementById("print");
      printEle.value += "appCallWeb：type=" + type + "，data=" + data + "\n";
    }

    function getUrlParams() {
      var urlParsms = window.location.href.split("?")[1];
      alert("获取url参数：" + urlParsms);
    }

    function goToLogin() {
      window.location.href = "http://dhzx.gitee.io/embed-h5/m/login";
    }

    function getAppToken() {
      var token = window.main.getAppToken();
      alert("获取App的token：" + token);
    }
  </script>
  <body>
    <h1>app-h5通讯测试</h1>
    <a href="/m/">进入内页</a>
    <br />
    <br />
    <br />
    <br />
    <div class="container">
      <button type="button" onClick="window.main.webCallApp('goTo','back')">
        App返回上一页</button
      ><br /><br /><br /><br />
      <button type="button" onClick="getAppToken()">获取App的token</button>
      <br /><br />
      <button type="button" onClick="getUrlParams()">获取url参数</button>
      <br /><br />
      <button type="button" onClick="goToLogin()">跳转到/m/login</button>
    </div>

    <textarea id="print"></textarea>
  </body>
</html>
<style>
  html,
  body {
    height: 100%;
  }
  body {
    text-align: center;
    font-size: 16px;
  }
  button {
    height: 50px;
    padding: 0 20px;
  }
  #print {
    margin-top: 20px;
    width: 90%;
    height: 300px;
  }
</style>
